<?php if (!defined('THINK_PATH')) exit();?><table id="zds_<?php echo ($index); ?>_dg"></table>


<div id="zdstool_<?php echo ($index); ?>">    
	<table>
		<tr>
			<?php if($index == 'bz'): ?><td>
					<?php if(authCheck1('Home/Zds/add')): ?><a href="#" id= "aaa1" class="easyui-linkbutton"  onclick='show_add_zds()' data-options="iconCls:'icon-standard-folder-page',plain:true">添加</a><?php endif; ?>
					<?php if(authCheck1('Home/Zds/del')): ?><a href="#" class="easyui-linkbutton"  onclick='dele_zds()' data-options="iconCls:'icon-standard-page-white-delete',plain:true">删除</a><?php endif; ?>
					<?php if(authCheck1('Home/Zds/edit')): ?><a href="#" class="easyui-linkbutton"  onclick='show_edit_zds()' data-options="iconCls:'icon-standard-application-edit',plain:true">编辑</a><?php endif; ?>
				</td>
				<td>
					<div class="datagrid-btn-separator"></div>
				</td><?php endif; ?>
			<td>
				<a href="#" class="easyui-linkbutton"  onclick="viewZds('<?php echo ($index); ?>')" data-options="iconCls:'icon-standard-application-view-gallery',plain:true">查看</a> 
			</td>
			<td>
				<div class="datagrid-btn-separator"></div>
			</td>
	<!-- 		<?php if(authCheck1('Home/Zds/edit')): ?><td>
				<a href="#" class="easyui-linkbutton"  onclick="will_invalid('<?php echo ($index); ?>')" data-options="iconCls:'icon-standard-application-view-gallery',plain:true">申请作废</a> 
			</td>
			<td>
				<div class="datagrid-btn-separator"></div>
			</td><?php endif; ?>   -->
			<td>
				<a href="#" class="easyui-linkbutton"  onclick="reloadZds('<?php echo ($index); ?>')" data-options="iconCls:'icon-standard-arrow-refresh',plain:true">刷新</a> 
			</td>
			<td>
				<div class="datagrid-btn-separator"></div>
			</td>
			<td>
				<div style="float:right;">        
					<input  id='search_zds_box_<?php echo ($index); ?>' class="easyui-searchbox" data-options="" style="width:400px;"/>
				</div>			  			      
				<div id="mm_zds_<?php echo ($index); ?>" style="width:400px">
					<div data-options="name:'content',iconCls:'icon-standard-table-edit',selected:true">全局搜索</div>
					<div data-options="name:'title',iconCls:'icon-standard-table-edit'">名称</div>
					<div data-options="name:'ids',iconCls:'icon-standard-table-edit'">编号</div>
					<div data-options="name:'nickname',iconCls:'icon-standard-table-edit'">作者</div>
				</div>
			</td>
			<td>
				<div class="datagrid-btn-separator"></div>
			</td>
			<td>
				<a href="#" id="finaZdsBtn<?php echo ($index); ?>" class="easyui-linkbutton"  onclick="finaSearchZds('<?php echo ($index); ?>')" data-options="iconCls:'icon-search',plain:true">显示高级搜索</a>
			</td>
			<td>
				<div class="datagrid-btn-separator"></div>
			</td>
			<td>
				
			<a href="#" id= "del_lsgd" class="easyui-linkbutton"  onclick='plug1()' data-options="iconCls:'icon-standard-server-uncompressed',plain:true">插件安装</a> 
			</td>

		</tr>
	</table>
	<!-- 全局搜索 -->
	<table  id="finaBoxZds_<?php echo ($index); ?>" style="display:none;">
		<tr >
			<td style="padding:0px 0px 0px 5px" colspan="5">
				<div class="table-btn-separator"></div>
			</td>
		</tr>
		<tr>
			<td>
				<div class="finaSeDiv">
					<label for="name">编号:</label>
					<input class="easyui-textbox" type="text" name="ids" id="f_<?php echo ($index); ?>_ids" style="width:130px" />
				</div>
			</td>
			<td>
				<div class="finaSeDiv">
					<label for="name">名称:</label>
					<input class="easyui-textbox" type="text" name="title" id="f_<?php echo ($index); ?>_title" style="width:130px" />
				</div>
			</td>
			<td>
				<div class="finaSeDiv">
					<label for="name">车间:</label>

					<input id="f_<?php echo ($index); ?>_cj" name="cj" class="easyui-textbox" data-options="iconCls:'',editable:true,panelHeight:'auto'"  style="width:130px" />


				</div>
			</td>
			<td>
				<div class="finaSeDiv">
					<label for="name">工位:</label>

					<select id="f_<?php echo ($index); ?>_gw" class="easyui-combobox" name="gws" style="width:130px;">   

					</select>  

					<!-- <input id="f_<?php echo ($index); ?>_gw" name="gws" class="easyui-textbox" data-options="iconCls:'',editable:true,panelHeight:'auto'"  style="width:130px" /> -->
				</div>
			</td>
			<td>
				<div class="finaSeDiv">
					<label for="name">车型/配置:</label>
					<input class="easyui-textbox" type="text" name="cx" id="f_<?php echo ($index); ?>_cx" style="width:130px" />
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<div class="finaSeDiv">
					<label for="name">分组:</label>

					<input id="f_<?php echo ($index); ?>_fz" class="easyui-combogrid" data-options="" name="fz[]" style="width:120px;"/>

				</div>
			</td>
			<td>
				<div>
					<label for="name">作者:</label>
					<input class="easyui-textbox" type="text" name="nickname" id="f_<?php echo ($index); ?>_nickname" style="width:130px" />
				</div>
			</td>
			<td colspan="2">


				<div class="finaSeDiv2">
					<label for="name">日期:</label>

					<input  name="creatdates" id="f_<?php echo ($index); ?>_creatdates"   type= "text" class= "easyui-datebox" style="width:100px"/>  到  
					<input  name="creatdatee" id="f_<?php echo ($index); ?>_creatdatee"   type= "text" class= "easyui-datebox" style="width:100px"/>

					<a  href="#" onclick="finaZds('<?php echo ($index); ?>')" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
				</div>
			</td>
		</tr>
	</table>
</div>


<!-- 下载插件 -->
<div id="plugd1" class="easyui-dialog" style="width:335px; height: 212px;padding: 10px 50px; overflow:hidden;" title="&nbsp;&nbsp;下载插件" data-options="iconCls:'icon-standard-folder-page',buttons:'#dlg-plugd1',closed:true,resizable:false,modal:true,closable:true">

    <a href="/solve/Public/word/weboffice7-exe.rar" target="_blank">&nbsp;weboffice插件</a><br>
    <a href="/solve/Public/word/ffactivex-setup-r39.rar" target="_blank">&nbsp;浏览器插件</a><br>
    请安装上面两个插件并在chrome浏览器或者360浏览器极速模式下使用作业指导书模块！
    <iframe id="iframe1" src="about:blank" frameBorder="0" marginHeight="0" marginWidth="0" style="position:absolute; visibility:inherit; top:0px;left:0px;width:100%; height:100%;z-index:-1; filter:alpha(opacity=0);"></iframe>

</div>
<div id="dlg-plugd1">
    <!-- <div class="tool_tip">只有自己发布的装配问题记录才能进行编辑！！</div> -->
    <!-- <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="downplug()">确认</a> -->
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#plugd1').dialog('close')">取消</a>
</div>


<script>
function plug1(){
$("#plugd1").dialog("open").dialog('setTitle', '&nbsp;&nbsp;下载插件');
// var html=`
// <a href="/solve/Public/word/weboffice7-exe.rar" target="_blank">&nbsp;weboffice插件</a><br>
//     <a href="/solve/Public/word/ffactivex-setup-r39.rar" target="_blank">&nbsp;浏览器插件</a><br>
//     请安装上面两个插件并在chrome浏览器或者360浏览器极速模式下使用作业指导书模块！
//     `;
// alert('<a href="/solve/Public/word/weboffice7-exe.rar" target="_blank">&nbsp;weboffice插件</a><br>'
//     <a href="/solve/Public/word/ffactivex-setup-r39.rar" target="_blank">&nbsp;浏览器插件</a><br>
//     请安装上面两个插件并在chrome浏览器或者360浏览器极速模式下使用作业指导书模块！');

}</script>

<script src="/solve/Public/App/zds/index.js"></script>





<script type="text/javascript">

// 显示添加指导书窗口





function show_edit_zds1(){
	var row = $('#zds_bz_dg').datagrid("getSelected");
	var group_id="<?php echo ($_SESSION['group_id']); ?>".split(",");
			
	if (row.uid == "<?php echo ($_SESSION[ 'uid']); ?>" || $.inArray("1", group_id)!=-1 || $.inArray("2", group_id)!=-1)  {
	if (row) {

		$("#editZds").dialog("open").dialog('setTitle', '&nbsp;&nbsp;编辑作业指导书');
		$("#urlspan").html('');



		$("#editZds_form").form("load", row);

		// $('#fz_edit').combogrid('setValue', row.fz);
		$('#fz_edit').combogrid('setValues', row.fz);


if(row.url!=''){
	var oldurl='<input  id="old_url"  style="width:650px;">';

	$('#urlspan').append(oldurl);
	$("#old_url").textbox({
			buttonText:'删除',
			iconCls:'icon-man',
			iconAlign:'right',
			onClickButton:function(){
				  $.messager.confirm('确认', '您确定要删除并重新上传新的作业指导书文件吗?', function(r) {
                    if (r) {
                        $.post('/solve/index.php/Home/Zds/delPdf', {
                             url : row.url,id : row.id
                        }, function(data) {
                            if (data.status==1) {                                                               
                                $("#urlspan").html('');
                                // $('#edit_ids').textbox('setValue',"");
                                $('#edit_title').textbox('setValue',"");

                                if($('#newUrl').length>0){
                                
                                }else{
                                		var newUrl="<input name='url' type='text' id='newUrl'/>";

                                $('#urlspan').append(newUrl);
                                // $("input#old_url").attr("name",'url');
                                $('#newUrl').filebox({    
                                    buttonText: '选择作业指导书文件', 
                                    buttonAlign: 'right',
                                    buttonIcon:'icon-add',
                                    accept:'application/pdf',
                                    width:'650px',
                                    prompt:'请选择PDF格式的作业指导书文件',
                                    onChange:function(){
								         addEditFile();
								    }

                                })
                                }
                                
                                 $.messager.alert('删除项目', data.data, 'info');
                                
                                
                            } else {
                                $.messager.show({ // show error message  
                                    title : '错误',
                                    msg : data.data
                                });

                            }
                        }, 'json');
                    }
                });
			}
		})
		//拼接url显示框数据
		$("#old_url").textbox('setText',row.title+'（'+row.url+'）');
}else{
		var newUrl="<input name='url' type='text' id='newUrl'/>";

                                $('#urlspan').append(newUrl);
                                // $("input#old_url").attr("name",'url');
                                $('#newUrl').filebox({    
                                    buttonText: '选择作业指导书文件', 
                                    buttonAlign: 'right',
                                    buttonIcon:'icon-add',
                                    accept:'application/pdf',
                                    width:'650px',
                                    prompt:'请选择PDF格式的作业指导书文件',
                                    onChange:function(){
								         addEditFile();
								    }

                                })
}
		

		

		// 初始化cj_edit
		var pid=$('#cj_edit').combobox('getValue');

        $('#gw_edit').combogrid({    
		    panelWidth:350,    
		    idField:'title',    
		    textField:'title',
			multiple:true,
		    striped: true,    
		    url:'/solve/index.php/Admin/Trem/cjList?pid='+pid,    
		    columns:[[    
		        {field:'title',title:'名称',width:120}  
		    ]]    
		});
        // gw_edit载入数据
        $('#gw_edit').combogrid('setValues', row.gw.split(","));
	} else {
		$.messager.alert("请选择要编辑的行", "请选择要编辑的行！", "info");
	}
	} else {

		$.messager.alert("无法删除", "此作业指导书非您创建，无法编辑！", "info");
	}
}


function edit_zds(){
		$('#editZds_form').form('submit', {
			type:'POST',
			 url : '/solve/index.php/Home/Zds/edit',
			success : function(data) {
				var data = eval('(' + data + ')');
				$('#editZds').dialog('close');
				$("#zds_bz_dg").datagrid("reload");
				$.messager.alert('编辑作业指导书', data.data, 'info');
				// 

			}
		});
}


 function getFileExt(str) 
{ 
var d=/\.[^\.]+$/.exec(str); 
return d; 
}
$('#zds_url').filebox({
    onChange:function(){
         addFile();
    }
});

function addFile(){
    var filename=$('#zds_url').filebox('getText');
      $('#title').textbox('setValue',filename);
    var fileExt=getFileExt(filename);
    if(fileExt!='.pdf'){
        $.messager.alert("格式错误", "上传的不是pdf文件", "info");
        return false;
    }
     // var ids=/\d{4}[TZE]{2,3}[(（]{1}艺{1}[）)]{1}-\d{5}/.exec(filename);//2017TZE
     //    if(ids==null){
            
     //        $('#ids').textbox('setValue',"");
            
         
     //        $.messager.alert("格式错误", "编号错误", "info");
     //     return false; 
     //    }else{
            
     //        $('#ids').textbox('setValue',ids);
        // }
        //  var title=/-[(（]{1}[\s\S]+\./.exec(filename);//2017TZE
        // if(title==null){
           
           
        //   $('#title').textbox('setValue',"");
            
        //     $.messager.alert("格式错误", "文件名错误", "info");
        //  return false; 
        // }else{
        //     var title=title[0].substr(2,title[0].length-4);
        //     $('#title').textbox('setValue',title);
        // }
   
}


$('#new_url').filebox({
    onChange:function(){
         var filename=$('#new_url').filebox('getText');
          $('#edit_title').textbox('setValue',filename);
          var fileExt=getFileExt(filename);
    if(fileExt!='.pdf'){
        $.messager.alert("格式错误", "上传的不是pdf文件", "info");
        return false;
    }
    }
});


function addEditFile(){
    var filename=$('#newUrl').filebox('getText');
    
    var fileExt=getFileExt(filename);
    if(fileExt!='.pdf'){
        $.messager.alert("格式错误", "上传的不是pdf图文件", "info");
        return false;
    }
     // var ids=/\d{4}[TZE]{2,3}[(（]艺{1}[）)]{1}-\d{5}/.exec(filename);//2017TZE
     //    if(ids==null){
            
     //        $('#edit_ids').textbox('setValue',"");
            
         
     //        $.messager.alert("格式错误", "编号错误", "info");
     //     return false; 
     //    }else{
            
     //        $('#edit_ids').textbox('setValue',ids);
     //    }
     //     var title=/-[(（]{1}[\s\S]+\./.exec(filename);//2017TZE
     //    if(title==null){
           
           
     //      $('#title').textbox('setValue',"");
            
     //        $.messager.alert("格式错误", "文件名错误", "info");
     //     return false; 
     //    }else{
     //        var title=title[0].substr(2,title[0].length-4);
     //        $('#edit_title').textbox('setValue',title);
     //    }
   
}
function viewZds(){

    var row = $('#zds_bz_dg').datagrid("getSelected");
        if (row) {
          
                          // 获取当前tab
    var tab = $('#tab').tabs('getSelected'); 
//encodeURI() 函数可把字符串作为 URI 进行编码
    tab.panel('refresh', '/solve/index.php/Home/Zds/view?id='+encodeURI(row.id));

        } else {
            $.messager.alert("请选择", "请选择要查看的作业指导书", "info");
        }
}
function reloadZds(){
	$("#zds_bz_dg").datagrid("reload", {   
		    cx: '' 
		});
}
function finaSearchZds(){
	$("#finaBoxZds").slideToggle(function(){
	 	if($('#finaZdsBtn').linkbutton("options").text=="显示高级搜索"){
		 	$('#finaZdsBtn').linkbutton({    
	    		text: '隐藏高级搜索'   
			}); 
	 	}else{
	 		 $('#finaZdsBtn').linkbutton({    
    			text: '显示高级搜索'   
			}); 
	 	}
	});
}
 function finaZds(){
 	// var gws=$("input[name='gws[]']");

 	// var gwArr=new Array();
 	// for(var i=0;i<gws.length;i++){
 	// 	gwArr[i]=gws[i].value;
 	// }

// if($('#f_gw')){
// 	gw=$('#f_gw').val()
// }else{
// 	gw="";
// }

 	$('#zds_bz_dg').datagrid('load',{
		ids:$("#f_ids").val(),
		title:$("#f_title").val(),
		cj:$('#f_cj').combobox('getValue'),
		gw:$('#f_gw').combobox('getValue'),
		fz:$('#ffz_edit').combobox('getValue'),
		cx:$("#f_cx").val(),
		nickname:$("#f_nickname").val(),
		dates:$("#f_creatdates").datebox('getValue'),
		datee:$("#f_creatdatee").datebox('getValue')
	});

}
</script>
<script src="/solve/Public/App/zds/index.js"></script>